<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>家庭书籍管理系统</title>
<link rel="stylesheet" href="css/thin_table.css">
</head>
<body onload="onInit();">
<table width="100%" border="0">
	<tr>
		<td>书籍管理 &gt;&gt;&gt;</td>
		<td><div align="right"> 书籍列表
				| <a href="/book_add.zweb?page_size=$$(PAGE_SIZE)&page_no=$$(PAGE_NO)">添加书籍</a> </div></td>
	</tr>
</table>
<br />
<form id="formQueryBook" name="formQueryBook">
	<table align="center">
		<tr>
			<td>书籍分类：
				<select name="selectBookClass" id="selectBookClass">
					<option value="">（所有）</option>
					
				$$[BOOK_CLASS/
				
					<option value="$$(BOOK_CLASS_CODE)" $$(BOOK_CLASS_SELECTED)>$$(PREFIX_AND_BOOK_CLASS_NAME)</option>
					
				$$/BOOK_CLASS]
			
				</select></td>
			<td>书名：
				<input name="textfieldBookTitle" type="text" id="textfieldBookTitle" value="$$(BOOK_TITLE)" size="60" maxlength="130" /></td>
			<td>书架：
				<select name="selectBookShelf" id="selectBookShelf" onchange="onChangeBookShelf();">
					<option value="">（所有）</option>
					
				$$[BOOK_SHELF/
				
					<option value="$$(BOOK_SHELF_ID)" $$(BOOK_SHELF_SELECTED)>$$(BOOK_SHELF_DESC)</option>
					
				$$/BOOK_SHELF]
			
				</select></td>
			<td>书架层：
				<select name="selectBookShelfLayer" id="selectBookShelfLayer">
					<option value="">（所有）</option>
					
				$$[BOOK_SHELF_LAYER/
				
					<option value="$$(BOOK_SHELF_LAYER_NUMBER)" $$(BOOK_SHELF_LAYER_SELECTED)>$$(BOOK_SHELF_LAYER_DESC)</option>
					
				$$/BOOK_SHELF_LAYER]
			
				</select></td>
			<td>标签备注：
				<input name="textfieldLabelRemark" type="text" id="textfieldLabelRemark" size="20" maxlength="32" /></td>
		</tr>
		<tr>
			<td colspan="5"><div align="right">
					<input type="button" name="buttonQueryBook" id="buttonQueryBook" value="   查询   " onclick="onSubmitQueryBook();" />
					<input type="button" name="buttonQueryBook" id="buttonQueryBook" value="   重置   " onclick="document.location.href='/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no=$$(PAGE_NO)';" />
				</div></td>
		</tr>
	</table>
</form>
<br />
<table class="thin_table" width="100%">
	<tr class="thin_table_tr">
		<td align="center"><strong>书籍分类</strong></td>
		<td align="center"><strong>书名</strong></td>
		<td align="center"><strong>作者</strong></td>
		<td align="center"><strong>出版社</strong></td>
		<td align="center"><strong>版次</strong></td>
		<td align="center"><strong>操作</strong></td>
	</tr>
	$$[NO_BOOK/
	<tr class="thin_table_tr">
		<td colspan="6" align="center">（没有书籍）</td>
	</tr>
	$$/NO_BOOK]
	$$[BOOK/
	<tr class="thin_table_tr">
		<td>$$(BOOK_CLASS_NAME)</td>
		<td>《$$(BOOK_TITLE)》</td>
		<td>$$(BOOK_AUTHOR)</td>
		<td>$$(BOOK_PUBLISHER)</td>
		<td>$$(BOOK_EDITION)</td>
		<td align="center"><a href="/book_info.zweb?book_id=$$(BOOK_ID)&page_size=$$(PAGE_SIZE)&page_no=$$(PAGE_NO)">详情</a> | <a href="/book_modify.zweb?book_id=$$(BOOK_ID)&page_size=$$(PAGE_SIZE)&page_no=$$(PAGE_NO)">修改</a> | <a href="#" onclick="confirmDelete('/book_removing.zweb?book_id=$$(BOOK_ID)&page_size=$$(PAGE_SIZE)&page_no=$$(PAGE_NO)');">删除</a> </td>
	</tr>
	$$/BOOK]
	<tr>
		<td colspan="6" align="right">第$$(PAGE_NO)页 总共$$(PAGE_COUNT)页
			<input type="hidden" name="hiddenPageCount" id="hiddenPageCount" value="$$(PAGE_COUNT)" />
			|
			$${HAS_FIRST_PAGE_HYPERLINK/ <a href="/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no=1"> $$/HAS_FIRST_PAGE_HYPERLINK} 首页 $${HAS_FIRST_PAGE_HYPERLINK/ </a> $$/HAS_FIRST_PAGE_HYPERLINK}
			| 
			$${HAS_PREV_PAGE_HYPERLINK/ <a href="/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no=$$(PREV_PAGE_NO)"> $$/HAS_PREV_PAGE_HYPERLINK} 上一页 $${HAS_PREV_PAGE_HYPERLINK/ </a> $$/HAS_PREV_PAGE_HYPERLINK}
			| 
			$${HAS_NEXT_PAGE_HYPERLINK/ <a href="/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no=$$(NEXT_PAGE_NO)"> $$/HAS_NEXT_PAGE_HYPERLINK} 下一页 $${HAS_NEXT_PAGE_HYPERLINK/ </a> $$/HAS_NEXT_PAGE_HYPERLINK}
			| 
			$${HAS_LAST_PAGE_HYPERLINK/ <a href="/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no=$$(LAST_PAGE_NO)"> $$/HAS_LAST_PAGE_HYPERLINK} 末页 $${HAS_LAST_PAGE_HYPERLINK/ </a> $$/HAS_LAST_PAGE_HYPERLINK}
			|
			跳到
			<input name="textfieldJumpToPageNo" type="text" id="textfieldJumpToPageNo" size="3" maxlength="3" />
			<input type="button" name="buttonJumpToPageNo" id="buttonJumpToPageNo" value="页" onclick="onJumpToPageNo();" />
		</td>
	</tr>
</table>
<script language="javascript">
	function onInit() {
		document.getElementById('textfieldJumpToPageNo').addEventListener('keydown', function(event) {
			if( event.key === 'Enter' || event.keyCode === 13 ) {
				event.preventDefault();
				onJumpToPageNo();
			}
		});
	}
	function confirmDelete( uri ) {
		if( confirm('确认删除该书籍信息？') ) {
			PostAhref( uri , null );
		}
	}
	function onChangeBookShelf() {
		var book_shelf = document.getElementById( 'selectBookShelf' ) ;
		
		var xhr = new XMLHttpRequest() ;
		xhr.open( 'GET' , '/book_shelf_layer_data.zweb?book_shelf_id='+book_shelf.value , true );
		xhr.responseType = 'json' ;
		xhr.onreadystatechange = function() {
			if( xhr.readyState == 4 && xhr.status == 200 ) {
				var selectBookShelfLayer = document.getElementById( 'selectBookShelfLayer' ) ;
				selectBookShelfLayer.innerHTML = '' ;
				var option = document.createElement('option') ;
				option.value = 0 ;
				option.textContent = "（所有）" ;
				selectBookShelfLayer.appendChild(option);
				xhr.response.forEach( function(item) {
					var option = document.createElement('option') ;
					option.value = item.book_shelf_layer_number ;
					option.textContent = item.book_shelf_layer_desc ;
					selectBookShelfLayer.appendChild(option);
				});
			}
		}
		xhr.onerror = function() {
			alert( 'Network error' );
		}
		xhr.send();
	}
	function onSubmitQueryBook() {
		var book_class = document.getElementById( 'selectBookClass' ) ;
		var book_title = document.getElementById( 'textfieldBookTitle' ) ;
		var book_shelf = document.getElementById( 'selectBookShelf' ) ;
		var book_shelf_layer = document.getElementById( 'selectBookShelfLayer' ) ;
		var label_remark = document.getElementById( 'textfieldLabelRemark' ) ;
		var uri = '/book_list_submit_query.zweb?query_book_class_code='+book_class.value+'&query_book_title='+encodeURIComponent(book_title.value)+'&query_book_shelf_id='+book_shelf.value+'&query_book_shelf_layer_number='+book_shelf_layer.value+'&query_label_remark='+label_remark.value ;
		document.location.href = uri ;
	}
	function onJumpToPageNo() {
		var page_count = document.getElementById( 'hiddenPageCount' ) ;
		var page_no = document.getElementById( 'textfieldJumpToPageNo' ) ;
		if( page_no.value < 1 || page_no.value > page_count.value ) {
			alert( '跳页号['+page_no.value+']无效' );
			return;
		}
		var uri = '/book_list.zweb?page_size=$$(PAGE_SIZE)&page_no='+page_no.value ;
		document.location.href = uri ;
	}
	function PostAhref( uri , target ) {
		var myForm = document.createElement( 'form' ) ;
		myForm.method = 'post' ;
		myForm.action = uri ;
		if( target != null )
			myForm.target = target ;
		document.body.appendChild( myForm );
		myForm.submit();
		document.body.removeChild( myForm );
	}
</script>
</body>
</html>
